#include "Player.h"


Player::Player(QGraphicsItem *parent, const QPointF& start_pos, int _type)
{
    moveLeft = moveRight = moveDown = moveUp = shoot = false;
    radius = 10;
    deathsNr = fragsNr = 0;
    leftAmmo = 5;
    setRect(0, 0, 2*radius, 2*radius);
    setPos(start_pos);
    setParentItem(parent);
    type = _type;

    img = new QImage;

    if (type == 1)
        img->load("../shared/player1.png");
    else if (type == 2)
        img->load("../shared/player3.png");
    else if (type == 3)
        img->load("../shared/player2.png");
}

void Player::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    QRectF r;
    r.setRect(0, 0, 2*radius, 2*radius);
    painter->drawImage(r, *img);
}


Player::~Player()
{
    delete img;
}
